package cn.edu.wynu.api.timeapi.time;

import java.time.LocalDate;
import java.time.LocalTime;

public class NewDateLearn {
    public static void main(String[] args) throws InterruptedException {
        // 新API的类型几乎全部是不变类型（和String类似）,一经调用now以后就不会再改变了
        LocalDate now = LocalDate.now();
        LocalTime now1 = LocalTime.now();
        System.out.println(now.toString() + " " + now1);

        // 获取开始时间戳
        long start = System.currentTimeMillis();
        System.out.println("start:" + start);

        // 休眠10秒
        Thread.sleep(10000);

        // 获取结束时间戳并计算时间差
        long end = System.currentTimeMillis();
        System.out.println("end:" + end);
        System.out.println("end - start = " + (end - start) + "ms");

        // 再次打印新时间api获取到的时间，发现值没有改变
        System.out.println(now.toString() + " " + now1);
    }
}
